<html>
<head><meta charset="utf-8"><title>Masks (take 3? 4?) · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html">Masks (take 3? 4?)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224133838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224133838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224133838">(Jan 27 2021 at 02:45)</a>:</h4>
<p>So I've been pondering masks again.  Reminder of where the latest iteration stands:</p>
<ul>
<li>Operations that use masks use an "opaque" mask by default.  The layout is architecture-specific.</li>
<li>An opt-in trait provides operations for specific mask layouts.</li>
</ul>
<p>A few things I don't like about this:</p>
<ul>
<li>The API is multiplied by the number of mask types (so at least 3).  Not pretty.</li>
<li>The trait is a little hacky--is it confusing to import? Does it need to be sealed?</li>
<li>Which mask layout should I be using?  It's not obvious.</li>
</ul>
<p>One thing that I realized (maybe it was obvious) that may help is that converting between masks is probably a very optimization-transparent operation--it's just sign extension!  I believe that if you do a comparison or other mask-producing function, and then immediately cast it to a different layout (e.g. llvm <code>sext</code>) the compiler likely does a good job optimizing it (e.g. using avx512 packed masks).</p>
<p>My new proposal:</p>
<ul>
<li>No traits.  Comparisons etc only produce the "opaque" mask.</li>
<li>Provide a set of layout-specified masks, such as <code>BitMask1&lt;N&gt;</code>, <code>BitMask8&lt;N&gt;</code>, <code>BitMask16&lt;N&gt;</code>.  These are all convertible between each other and the opaque mask.</li>
<li>Provide masking operations (e.g. <code>BitAnd</code>) for all masks, both opaque and layout-specified.</li>
</ul>
<p>I believe this would minimize the API while still allowing weird mixed-layout tricks like avx512 packed masks and SSE movemask.  For example, if you want a packed comparison on x86-64 you may use <code>let mask: BitMask1 = a.lanes_eq(b).into()</code>.  On SSE this would hopefully optimize to cmpeq and movemask, and on avx512 it may choose to use cmpeq_mask.</p>



<a name="224271664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224271664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224271664">(Jan 28 2021 at 00:59)</a>:</h4>
<p>bump (kinda got drowned out with PR talk yesterday)</p>



<a name="224273902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224273902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224273902">(Jan 28 2021 at 01:28)</a>:</h4>
<p>From a purely API perspective that sounds like a better approach to me! Fewer traits is good</p>



<a name="224274494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224274494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224274494">(Jan 28 2021 at 01:37)</a>:</h4>
<p>Yeah my thoughts exactly.  We need to add a compiler intrinsic for sign extension up and down from packed masks to full masks before we can be positive it optimizes well. (But we need that intrinsic regardless of the API we choose, I think)</p>



<a name="224274731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224274731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224274731">(Jan 28 2021 at 01:40)</a>:</h4>
<p>I'm optimistic (heh) though, because that's already how the backend produces masks anyway:<br>
<a href="https://github.com/rust-lang/rust/blob/d3163e96553ae8cb1fca0e62084b124e8b98310b/compiler/rustc_codegen_ssa/src/base.rs#L118-L122">https://github.com/rust-lang/rust/blob/d3163e96553ae8cb1fca0e62084b124e8b98310b/compiler/rustc_codegen_ssa/src/base.rs#L118-L122</a></p>



<a name="224275854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224275854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224275854">(Jan 28 2021 at 01:57)</a>:</h4>
<p>My mind is somewhat murky at the moment for... reasons... but it seems like a cool idea and aligns with my interests so. <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="224279582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224279582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224279582">(Jan 28 2021 at 03:09)</a>:</h4>
<p>A bit of a silly example, but I did confirm that llvm can see through successive <code>sext</code> and <code>trunc</code>: <a href="https://gcc.godbolt.org/z/1crd6v">https://gcc.godbolt.org/z/1crd6v</a></p>



<a name="224279630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224279630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224279630">(Jan 28 2021 at 03:10)</a>:</h4>
<p>if you remove the <code>--mattr</code> it uses movemask as expected, as well</p>



<a name="224279913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224279913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224279913">(Jan 28 2021 at 03:16)</a>:</h4>
<p>i certainly like less types and less traits</p>



<a name="224390387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224390387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224390387">(Jan 28 2021 at 20:47)</a>:</h4>
<p>Okay, yes. Seeing the compilation work out makes this look plausible. <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span><br>
This looks pretty close to what I was gunning for in the first place, I think I need to dredge the backlog to see what the closest proposal to it was and what the objections were to it just to make sure those have been settled.</p>



<a name="224390478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224390478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224390478">(Jan 28 2021 at 20:47)</a>:</h4>
<p>Yeah, I think it's close to what I originally wanted as well, I think it just didn't click that these are fairly transparent operations to the compiler</p>



<a name="224390643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224390643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224390643">(Jan 28 2021 at 20:49)</a>:</h4>
<p>I think I'll open a PR adding mask pack and unpack intrinsics so we can actually use it</p>



<a name="224394384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394384">(Jan 28 2021 at 21:21)</a>:</h4>
<p>I know that the main objection to all the opaque-mask-centric proposals is generally that we basically have to be able to believe the compiler can handle it correctly, and also that x86, just to mess with us, never decided to consistently use one type of mask, but x86-targeted optimizations are inevitably going to be demanded.</p>



<a name="224394590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394590">(Jan 28 2021 at 21:23)</a>:</h4>
<p>My argument would be that LLVM already requires being able to see through zero extension, since all masks are &lt;N x i1&gt;</p>



<a name="224394724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394724">(Jan 28 2021 at 21:24)</a>:</h4>
<p>Agreed that it's relying heavily on the optimizer though (but what doesn't at this point, I guess)</p>



<a name="224394754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394754">(Jan 28 2021 at 21:24)</a>:</h4>
<p>hypothetical contention: but why CAN'T we specify masks as N x i8 or whatever if we want? :V</p>



<a name="224394813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394813">(Jan 28 2021 at 21:25)</a>:</h4>
<p>All of LLVM's mask instructions take a mask lane as an i1</p>



<a name="224394821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394821">(Jan 28 2021 at 21:25)</a>:</h4>
<p>oh, I see.</p>



<a name="224394830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394830">(Jan 28 2021 at 21:25)</a>:</h4>
<p>...well!</p>



<a name="224394845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394845">(Jan 28 2021 at 21:25)</a>:</h4>
<p>Which honestly makes sense and is really platform-agnostic</p>



<a name="224394878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224394878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224394878">(Jan 28 2021 at 21:25)</a>:</h4>
<p>It's just weird when it comes to memory layout</p>



<a name="224396475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224396475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224396475">(Jan 28 2021 at 21:41)</a>:</h4>
<p>I see.<br>
How did that not come up in previous discussions?</p>



<a name="224417269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224417269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224417269">(Jan 29 2021 at 00:45)</a>:</h4>
<p>I'm pretty sure I mentioned (in the thread where I argued for including opaque masks) that LLVM IR operates only on i1 vectors for masks...</p>



<a name="224418000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224418000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224418000">(Jan 29 2021 at 00:55)</a>:</h4>
<p>Yeah I think we discussed it, probably just got lost in the discussion</p>



<a name="224425374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224425374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224425374">(Jan 29 2021 at 02:53)</a>:</h4>
<p>the issue is it's really trivial to come up with examples where the optimizer completely falls on its face to a ridiculous extent with &lt;N x i1&gt; masks. like, whenever stuff isn't fully inlined and a mask is returnd across a function call boundary.</p>



<a name="224425434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224425434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224425434">(Jan 29 2021 at 02:54)</a>:</h4>
<p>That was definitely a bitcast issue</p>



<a name="224425472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224425472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224425472">(Jan 29 2021 at 02:55)</a>:</h4>
<p>If you <code>bitcast</code> to u8 or similar the element alignment isn't ambiguous anymore and it gets the layout correct</p>



<a name="224430452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224430452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224430452">(Jan 29 2021 at 04:43)</a>:</h4>
<p>so basically the issue can be handled but has to be handled in LLVM codegen?</p>



<a name="224430513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224430513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224430513">(Jan 29 2021 at 04:44)</a>:</h4>
<p>I think it's not just codegen, it's actually in the function signatures.  We don't really want to pass vectors of i1s between functions, we want to pass vectors of u8s that we happen to treat as i1s</p>



<a name="224430531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224430531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224430531">(Jan 29 2021 at 04:45)</a>:</h4>
<p>i1 has byte alignment (usually?)</p>



<a name="224430616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224430616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224430616">(Jan 29 2021 at 04:47)</a>:</h4>
<p>LLVM doesn't really make it clear, but it appears that the calling convention is that all vectors regardless of size have at a minimum byte aligned elements</p>



<a name="224430675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224430675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224430675">(Jan 29 2021 at 04:48)</a>:</h4>
<p>e.g. you could bytecast &lt;2 x i4&gt; to a single i8 but at a call site it's 2 bytes</p>



<a name="224430756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224430756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224430756">(Jan 29 2021 at 04:50)</a>:</h4>
<p>An alternative way of saying it is at call sites, it treats vectors like any regular array or struct</p>



<a name="224431514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224431514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224431514">(Jan 29 2021 at 05:09)</a>:</h4>
<p>huh, wild.</p>



<a name="224526431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224526431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224526431">(Jan 29 2021 at 20:09)</a>:</h4>
<blockquote>
<p>We don't really want to pass vectors of i1s between functions, we want to pass vectors of u8s that we happen to treat as i1s</p>
</blockquote>
<p>I'm kind of skeptical this solves the issue, to be honest (I could be convinced, but need examples). vector-of-u8 still often won't be to be the actual native mask representation, and in practice needs conversion to/from</p>



<a name="224526628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224526628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224526628">(Jan 29 2021 at 20:10)</a>:</h4>
<p>What do you mean by native mask?</p>



<a name="224526822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224526822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224526822">(Jan 29 2021 at 20:12)</a>:</h4>
<p>A vector of u8s is negligibly different from some number of k registers in avx512, for example (and llvm does in fact use them when appropriate)</p>



<a name="224527834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224527834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224527834">(Jan 29 2021 at 20:21)</a>:</h4>
<p>This is still a somewhat contrived example, but this packs two k registers together to produce a packed vector:</p>



<a name="224527839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224527839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224527839">(Jan 29 2021 at 20:21)</a>:</h4>
<p><a href="https://gcc.godbolt.org/z/6K4YYb">https://gcc.godbolt.org/z/6K4YYb</a></p>



<a name="224528172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224528172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224528172">(Jan 29 2021 at 20:24)</a>:</h4>
<p>Here is the same example, but without the bitcast:<br>
<a href="https://gcc.godbolt.org/z/9hrPrY">https://gcc.godbolt.org/z/9hrPrY</a><br>
LLVM forces each i1 to be byte aligned at the function call boundary</p>



<a name="224528226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224528226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224528226">(Jan 29 2021 at 20:25)</a>:</h4>
<p>(it's suprisingly good at doing that efficiently, too)</p>



<a name="224530285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530285">(Jan 29 2021 at 20:43)</a>:</h4>
<p>It generated much worse code for non-avx512 though. Most code currently is compiled with default settings, and I think its realistic to assume that will continue, and so whatever we choose needs to work well for the for SSE2-default you get with default-settings x86_64.</p>



<a name="224530463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530463">(Jan 29 2021 at 20:45)</a>:</h4>
<p><a href="https://gcc.godbolt.org/z/Ga9c4v">https://gcc.godbolt.org/z/Ga9c4v</a></p>



<a name="224530471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530471">(Jan 29 2021 at 20:45)</a>:</h4>
<p>Here's the non-avx512 variant</p>



<a name="224530479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530479">(Jan 29 2021 at 20:45)</a>:</h4>
<p>This looks pretty good to me?</p>



<a name="224530588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530588">(Jan 29 2021 at 20:46)</a>:</h4>
<p>It packs all of the results together and movemasks them to produce the packed mask</p>



<a name="224530661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530661">(Jan 29 2021 at 20:46)</a>:</h4>
<p>I doubt there is a better way of doing that?  Remember, this won't be the default mask on x86-64, those will still be full lane-width masks</p>



<a name="224530814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530814">(Jan 29 2021 at 20:48)</a>:</h4>
<p>This is more representative of the default mask mode on x86-64: <a href="https://gcc.godbolt.org/z/3hbWhx">https://gcc.godbolt.org/z/3hbWhx</a></p>



<a name="224530821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530821">(Jan 29 2021 at 20:48)</a>:</h4>
<blockquote>
<p>Remember, this won't be the default mask on x86-64, those will still be full lane-width masks</p>
</blockquote>
<p>I guess I misunderstood what you were saying earlier then</p>



<a name="224530922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530922">(Jan 29 2021 at 20:49)</a>:</h4>
<p>Oh sorry.  On x86-64/arm/aarch64/etc a mask will still be by default lane-width</p>



<a name="224530982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224530982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224530982">(Jan 29 2021 at 20:49)</a>:</h4>
<p>You only get these if you explicitly use <code>Into::into</code> to get a packed layout mask</p>



<a name="224531060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224531060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224531060">(Jan 29 2021 at 20:50)</a>:</h4>
<p>You can also use <code>Into::into</code> to get the unpacked layout mask, but that is a nop on x86-64</p>



<a name="224538330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224538330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224538330">(Jan 29 2021 at 21:48)</a>:</h4>
<p>I feel like, for x86-64, we basically have three actual targets:<br>
baseline<br>
AVX2 ("any recent processor")<br>
AVX512 ("really recent high-performance things")</p>



<a name="224539064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224539064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224539064">(Jan 29 2021 at 21:55)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> <a href="https://www.phoronix.com/scan.php?page=news_item&amp;px=GCC-11-x86-64-Feature-Levels">https://www.phoronix.com/scan.php?page=news_item&amp;px=GCC-11-x86-64-Feature-Levels</a></p>



<a name="224539202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224539202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224539202">(Jan 29 2021 at 21:56)</a>:</h4>
<p>You're basically describing the v1, v3, and v4 levels here I think</p>



<a name="224539337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224539337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224539337">(Jan 29 2021 at 21:57)</a>:</h4>
<p>I think generally we can assume up to sse4.2 even if it's not on by default</p>



<a name="224545716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224545716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224545716">(Jan 29 2021 at 22:40)</a>:</h4>
<p>yeah, sse4 and avx are "extremely common", avx2 is also "usual", though not always present</p>



<a name="224552394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224552394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224552394">(Jan 30 2021 at 00:00)</a>:</h4>
<p><span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="224556331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224556331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224556331">(Jan 30 2021 at 00:57)</a>:</h4>
<p>yeah, I described v3 because most of the computers I've used lately are like... either v3 or verrry late v2, and I mostly use potatos. So honestly I'm not surprised I suddenly had a breakage spree, I just am sad.</p>



<a name="224616482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224616482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224616482">(Jan 31 2021 at 01:48)</a>:</h4>
<p>v3 is also important since the currently highest-performance x86 processors (AMD Ryzen 5950X or AMD Threadripper 3990X) both don't support AVX512</p>



<a name="224619793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224619793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224619793">(Jan 31 2021 at 03:30)</a>:</h4>
<p>Yep! That is Very Much part of the reason I was thinking about AVX2 specifically.</p>



<a name="224619846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224619846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224619846">(Jan 31 2021 at 03:32)</a>:</h4>
<p>Agreed that v3 is probably where most CPUs are.  I've only used one consumer device with AVX512...</p>



<a name="224620949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224620949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224620949">(Jan 31 2021 at 04:07)</a>:</h4>
<p>it seems likely to me that avx512 will stay as a server hardware thing tbh. it's been around for a while and hasn't moved over except in rare cases.</p>



<a name="224665149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224665149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224665149">(Jan 31 2021 at 21:17)</a>:</h4>
<p>Yeah, I expect that whatever comes next, we won't be just going forward into a "level 5". Much like certain err, other failed experiments from the past.<br>
lookin' at you MMX. ( but also there were a few other abortive extensions from AMD as well. )</p>



<a name="224665765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224665765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224665765">(Jan 31 2021 at 21:31)</a>:</h4>
<p>Another thought on mask layout, do we actually need masks that have particular layouts?  Or should masks just have a few methods like to_int/from_int and to_bits/from_bits</p>



<a name="224665923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224665923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224665923">(Jan 31 2021 at 21:34)</a>:</h4>
<p>I think within a particular function, mask layout almost doesn't matter since the compiler is allowed to do whatever it wants (e.g. use avx512 k registers even if you're using full-width masks).  It only really matters when you are writing masks to memory (which is probably rare with SIMD, even non-inlined functions are rare)</p>



<a name="224666051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224666051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224666051">(Jan 31 2021 at 21:37)</a>:</h4>
<p>There would be nothing preventing you from writing a "mask" type that has a particular layout if we provide those functions, but we can avoid type bloat that almost no one needs</p>



<a name="224666105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224666105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224666105">(Jan 31 2021 at 21:38)</a>:</h4>
<p>(and of course they could be added in the future)</p>



<a name="224666106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224666106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224666106">(Jan 31 2021 at 21:38)</a>:</h4>
<p>From my perspective, it's a sort of weird space between core::arch and core::simd</p>



<a name="224670415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224670415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224670415">(Jan 31 2021 at 22:47)</a>:</h4>
<p>what we really want to be able to do is allow people to convert it explicitly into the machine mask type.</p>



<a name="224670630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224670630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224670630">(Jan 31 2021 at 22:52)</a>:</h4>
<p>Agreed, I think</p>



<a name="224670775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224670775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224670775">(Jan 31 2021 at 22:56)</a>:</h4>
<p>I think that's what to_int and to_bits would do, more or less</p>



<a name="224671009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224671009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224671009">(Jan 31 2021 at 23:02)</a>:</h4>
<p>to_bits of course is still problematic because of the const bound</p>



<a name="224671594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224671594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224671594">(Jan 31 2021 at 23:16)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=a562af6ab4f2284ebb9322971f1cbd12">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=a562af6ab4f2284ebb9322971f1cbd12</a></p>



<a name="224671622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224671622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224671622">(Jan 31 2021 at 23:17)</a>:</h4>
<p>I suppose something like this may be okay.  Only the implementation of the trait requires an unstable feature, the trait itself is fairly standard rust</p>



<a name="224966954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224966954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224966954">(Feb 03 2021 at 02:38)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> question about RISC-V, if you had a non-power of two vector would a mask be some number of bytes with the last byte partially empty (e.g. 2 bytes for a vector of 10 u8s)?</p>



<a name="224977532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224977532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224977532">(Feb 03 2021 at 06:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F)/near/224966954">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> question about RISC-V, if you had a non-power of two vector would a mask be some number of bytes with the last byte partially empty (e.g. 2 bytes for a vector of 10 u8s)?</p>
</blockquote>
<p>I don't actually know.</p>



<a name="224977654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224977654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224977654">(Feb 03 2021 at 06:13)</a>:</h4>
<p>On SimpleV, masks are always 64-bit integers where the bits are matched to vector elements from the LSB to the MSB, the bits past the number of used vector elements are just ignored</p>



<a name="224977876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224977876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224977876">(Feb 03 2021 at 06:16)</a>:</h4>
<p>Hm, that makes sense</p>



<a name="224978003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224978003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224978003">(Feb 03 2021 at 06:18)</a>:</h4>
<p>So the issue that I am seeing here is that the memory layout of masks will be inherently architecture specific.  SimpleV uses 64 bits, AVX-512 uses 16 bits, and just to make things more confusing AVX-512BW uses 64 bits</p>



<a name="224978034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224978034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224978034">(Feb 03 2021 at 06:19)</a>:</h4>
<p>Even if we can manage to get a type that uses a packed representation, I'm not sure it's possible to get the layout correct</p>



<a name="224978235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224978235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224978235">(Feb 03 2021 at 06:22)</a>:</h4>
<p>So then the question becomes does the memory layout actually matter.  Do we care what a mask looks like in memory rather than a register (and is that a valid question for RISC-V or SimpleV?)</p>



<a name="224978388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224978388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224978388">(Feb 03 2021 at 06:25)</a>:</h4>
<p>That may sound like a silly question but my point is that the layout only matters in 2 scenarios I can think of, when you run out of SIMD registers and push them to memory (undesirable) or when you push the SIMD registers to regular registers for a function call (also undesirable, I think).  Within a single function LLVM doesn't particularly care what the layout is and will optimize it</p>



<a name="224978473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224978473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224978473">(Feb 03 2021 at 06:26)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> curious if you have anything to add about that for x86-64</p>



<a name="224982996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224982996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224982996">(Feb 03 2021 at 07:43)</a>:</h4>
<blockquote>
<p>Do we care what a mask looks like in memory rather than a register (and is that a valid question for RISC-V or SimpleV?)</p>
</blockquote>
<p>I mean the answer is: yes certain algorithms need certain mask layouts for lookup tables and such, which will be in memory. IDK if you can really fully avoid having to represent both bit masks and wide masks because of this. (Even in SSE2 I've done lots of bitmask stuff, but with the very big caveat that it's wide=&gt;bit and never the reverse)...</p>
<p>Note that I haven't been following closely, so I'm possibly missing the point here... Are we talking about reducing the number of masks in the API? or what's our problem with it?</p>



<a name="224983102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/224983102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#224983102">(Feb 03 2021 at 07:44)</a>:</h4>
<p>So, if <em>is</em> the complexity... well, I do have some thoughts here I kicked around for a while ago. Since I was actively pinged I'll put them down despite them possibly not being on topic (people talking past eachother is normal for the project-portable-simd mask thread anyway). Basically it comes down to this:</p>
<ol>
<li>
<p>The overhead of converting between wide masks and bitmasks on arches/ISAs that can natively use bitmasks was really quite low. Like, IIRC on the order of 1 or 2 fairly cheap instructions or something<br>
    a. for example, wide=&gt;bit is just comparison vs a constant, and bit=&gt;wide is a masked store or similar. (there are def other ways to do these too, that may be even better)<br>
    b. That said, perhaps I'm missing something here...</p>
</li>
<li>
<p>Conversely, the overhead of converting between wide masks and bitmasks where native bitmasks <em>aren't</em> supported is... kinda awful.<br>
    a. Going <em>to</em> a bitmask is not so bad. On x86 has movemask, ppc has some bit permute thing... On Neon it kinda sucks (need to use multiple steps of shift + add or something) but... well, it's still basically straightforward enough (just maybe 10x more costly)<br>
    b. Sadly, bitmask to wide mask basically needs native bitmask ops to be efficient at all (I suspect there's a few tricks you can do with more obscure x86 or neon instructions to come up with a better techinque for it than "scalar iteration over each bit", but honestly it's not coming to mind). That said, nobody's suggesting we make widemask isas work with bitmasks any more than they have to.</p>
</li>
<li>
<p>There's a similar story for going between other representations and your desired mask repr. For example: converting in-memory &lt;i1 x N&gt; to/from a native mask type:<br>
    a. if native is a bitmask would be essentially the exact same as the operations i noted in 1a.<br>
    b. if it's not... well, bytemask&lt;=&gt;widemask is a lot more tractable than the bitmask case, but it was still <em>truly terrible</em>, and probably would be everwhere (well, ppc can probably do both directions okay actually).</p>
</li>
</ol>
<p>This just makes me feel like in general it's probably something of a lowest-common-denominator sitch. ISAs that like wide masks <em>really</em> want to keep the masks wide in the exact bit width they started with, and do few (ideally no) conversions.</p>
<p>ISAs that like bitmasks tend to be able to convert more easily, and I strongly suspect that it's much easier an optimizer (even a naive one) to see through the conversions in this case.</p>
<p>That said, while I don't think I've covered it this explicitly before, i definitely have said most of these things in one of these threads.</p>



<a name="225031482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225031482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225031482">(Feb 03 2021 at 15:30)</a>:</h4>
<p>Okay, let me try to clarify what the problem is.</p>
<p>The first and most fundamental issue is that Rust doesn't provide any good mechanism for making the single bit mask type.  I've played around with it a lot but there just isn't a good solution.  There are ways to just barely get it working but it requires const_evaluatable_checked which seems far from complete.</p>
<p>The next problem is that even if we do manage to get single-bit masks working, the native mask type is different for different architectures.  A simple <code>[u8; BYTES]</code> is the best we can do.</p>
<p>One option is to instead of providing multiple mask layouts, simply make masks convertible to and from integers.  We can implement <code>Into</code> for all masks up to 128 width and convert them to all integers up to u128.  If we had arbitrary sized integers it would actually solve this problem, just convert to an integer with the same number of bits as lanes!  But for now this may be the best we can do.</p>
<p>This would mean that when using AVX-512 or SimpleV, if you let a mask go to memory without converting it to an integer, you will probably not end up with the behavior you want.  However if you call <code>into</code> before going to memory, you should end up with the layout you expect.</p>



<a name="225032084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225032084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225032084">(Feb 03 2021 at 15:34)</a>:</h4>
<p>If we really wanted to, we could look to see what it would take to get arbitrary sized integers into Rust <span class="user-mention" data-user-id="281757">@Jubilee</span> <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="225055496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225055496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225055496">(Feb 03 2021 at 18:05)</a>:</h4>
<p>How large would the integers need to be? even for 512-bit vectors with 8 bit elements, that's still 64 bits... Or does variable mean dynamically sized?</p>



<a name="225056022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225056022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225056022">(Feb 03 2021 at 18:09)</a>:</h4>
<p>Well to support common cases we could just do everything that works up to u128.  You can absolutely make vectors larger than that (you could have a vector with 2^15 lanes)</p>



<a name="225056463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225056463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225056463">(Feb 03 2021 at 18:12)</a>:</h4>
<p>When I say variable, I mean there have been proposed features to make something like u3 or u7 or u19 possible.</p>



<a name="225056513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225056513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225056513">(Feb 03 2021 at 18:12)</a>:</h4>
<p>That would be very convenient here, if we could just use an integer with the same number of bits as we have lanes</p>



<a name="225056709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225056709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225056709">(Feb 03 2021 at 18:14)</a>:</h4>
<p>/me twiddles thumbs, hmming.</p>



<a name="225057358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225057358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225057358">(Feb 03 2021 at 18:18)</a>:</h4>
<p>I guess the summary is that with bitmasks we are trying to push the limits of what const generics support so, we either need to punt on the feature (trying not to preclude them in the future) or implement _something_ new in the compiler</p>



<a name="225057481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225057481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225057481">(Feb 03 2021 at 18:19)</a>:</h4>
<p>Or compromise on them, like only implementing them for a few integers (and hopefully this doesn't preclude a better implementation in the future)</p>



<a name="225058052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058052">(Feb 03 2021 at 18:23)</a>:</h4>
<p><a href="https://github.com/rust-lang/rfcs/pull/2581">https://github.com/rust-lang/rfcs/pull/2581</a></p>



<a name="225058333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058333">(Feb 03 2021 at 18:24)</a>:</h4>
<p>I think we might have a better reason to add arbitrary-sized integers if we combine SIMD bitmasks and C bitfields as aadditiomal motivating reasons</p>



<a name="225058334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058334">(Feb 03 2021 at 18:24)</a>:</h4>
<p>Well, after your PR lands, we'll only have compiler support for 2^(1..=15) element vectors, which is probably well beyond what we need on any practical level at this red hot second.</p>



<a name="225058466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058466">(Feb 03 2021 at 18:25)</a>:</h4>
<p>My concern is more about making sure the API doesn't preclude a better implementation in the future</p>



<a name="225058616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058616">(Feb 03 2021 at 18:26)</a>:</h4>
<p>Right.</p>



<a name="225058712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058712">(Feb 03 2021 at 18:27)</a>:</h4>
<p>I would also like to try to avoid const_evaluatable_checked at all costs at this point</p>



<a name="225058793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058793">(Feb 03 2021 at 18:27)</a>:</h4>
<p>Particularly because it bleeds into the public API</p>



<a name="225058996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225058996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225058996">(Feb 03 2021 at 18:29)</a>:</h4>
<blockquote>
<p><a href="https://github.com/rust-lang/rfcs/pull/2581">https://github.com/rust-lang/rfcs/pull/2581</a></p>
</blockquote>
<p>I kind of like the idea of a Bit type mentioned in one of the comments.  Even if we can get that into unstable, we can hide it behind a mask wrapper</p>



<a name="225059218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059218">(Feb 03 2021 at 18:30)</a>:</h4>
<p>what about using the rustc private attributes to make a u1, u2, and u4 that are range-limited newtype around u8, then we'd have all the types we need for up to 128-bit masks assuming lane-counts are powers of 2. When we eventually get built-in arbitrary-sized integers, the u1, u2, and u4 types can then become type aliases of uint&lt;1&gt;, uint&lt;2&gt;, and uint&lt;4&gt;</p>



<a name="225059368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059368">(Feb 03 2021 at 18:31)</a>:</h4>
<p>Trying to be realistic for a moment here,<br>
I need to doublecheck SVE2 but I believe it does enable non-2^N vector sizes, but still has a limiter of 2048 bits wide, which makes having non-2^N vectors more important, relatively speaking, than having ones of indefinite size.</p>



<a name="225059388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059388">(Feb 03 2021 at 18:31)</a>:</h4>
<p>...yep.</p>



<a name="225059660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059660">(Feb 03 2021 at 18:33)</a>:</h4>
<p>except that on SVE, cpus are only guaranteed to support 128 or 256-bits (iirc), all the larger sizes are not guaranteed to be supported</p>



<a name="225059674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059674">(Feb 03 2021 at 18:33)</a>:</h4>
<p>Yeah, one issue is non-power-of-two vectors (which right now is only limited because of cranelift)</p>



<a name="225059750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059750">(Feb 03 2021 at 18:33)</a>:</h4>
<p>I would also like to use const generics from the start if possible, so we can avoid changing trait implementations in the future</p>



<a name="225059805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059805">(Feb 03 2021 at 18:34)</a>:</h4>
<p>Though perhaps we can be careful with it</p>



<a name="225059844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225059844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225059844">(Feb 03 2021 at 18:34)</a>:</h4>
<p>what about just stating that if you want to use SVE, you have to use llvm?</p>



<a name="225060021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060021">(Feb 03 2021 at 18:35)</a>:</h4>
<p>Sorry that's not exactly the problem.  What I mean is that in the near future you may be able to use e.g. <code>SimdU8&lt;5&gt;</code> and if we use explicitly sized integers rather than something generic it falls apart there</p>



<a name="225060038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060038">(Feb 03 2021 at 18:35)</a>:</h4>
<p>that can be done like array lengths were, have a sealed trait <code>IsSupportedPowerOf2&lt;LEN&gt;</code> impled for <code>()</code> for only 1, 2, 4, 8, 16, 32, 64, and 128.</p>



<a name="225060149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060149">(Feb 03 2021 at 18:36)</a>:</h4>
<p>Right but what is the Into trait implemented on</p>



<a name="225060188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060188">(Feb 03 2021 at 18:36)</a>:</h4>
<p>Hm</p>



<a name="225060215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060215">(Feb 03 2021 at 18:36)</a>:</h4>
<p>Maybe it's fine</p>



<a name="225060251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060251">(Feb 03 2021 at 18:37)</a>:</h4>
<p>trait <code>EnoughBitsToConvertTo&lt;Target  BITS&gt;</code></p>



<a name="225060609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060609">(Feb 03 2021 at 18:39)</a>:</h4>
<p>I would like our eventual plan to be to expose bitmask conversion from/to built-in uint&lt;N&gt;</p>



<a name="225060902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060902">(Feb 03 2021 at 18:41)</a>:</h4>
<p>Yeah, agreed</p>



<a name="225060972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225060972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225060972">(Feb 03 2021 at 18:41)</a>:</h4>
<p>I am at this point convinced that, based on our amount of uncertainty and discussion, breaking our mask API at some point as we rework it is inevitable and in fact almost desirable, and that we should ship the mask API under a separate feature gate, so that shipping core::simd does not depend on the entirety of things being stable.</p>



<a name="225061096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061096">(Feb 03 2021 at 18:42)</a>:</h4>
<p>My only concern with that is that simd is almost unusable without masks, and we'll never stabilize</p>



<a name="225061143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061143">(Feb 03 2021 at 18:42)</a>:</h4>
<p>initial arbitrary-sized integer implementation: <a href="https://github.com/rust-lang/rfcs/pull/2581#issuecomment-730709707">https://github.com/rust-lang/rfcs/pull/2581#issuecomment-730709707</a></p>



<a name="225061272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061272">(Feb 03 2021 at 18:43)</a>:</h4>
<p>...does linear algebra depend on masking?</p>



<a name="225061367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061367">(Feb 03 2021 at 18:44)</a>:</h4>
<p>the opaque mask type should be stable...just the conversions to bitmasks are unstable</p>



<a name="225061420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061420">(Feb 03 2021 at 18:44)</a>:</h4>
<p>Okay, I suppose "do math fast" doesn't need it. Which is all I need it for usually. But it's crucial for many applications</p>



<a name="225061459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061459">(Feb 03 2021 at 18:44)</a>:</h4>
<p>well we're at 100% unstable right now so that is wishful thinking. :^)</p>



<a name="225061551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061551">(Feb 03 2021 at 18:45)</a>:</h4>
<p>Right, my contention is that atm we should get "let's do math fast" on stable. :^)</p>



<a name="225061552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061552">(Feb 03 2021 at 18:45)</a>:</h4>
<p>It's hard to stabilize the opaque mask when were not sure if the type will need bounds or not. Currently with const_evaluatable_checked it needs bounds</p>



<a name="225061598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061598">(Feb 03 2021 at 18:45)</a>:</h4>
<p>that would be at the point where the main simd feature gate is stable but masks are not yet</p>



<a name="225061755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061755">(Feb 03 2021 at 18:46)</a>:</h4>
<p>can we have a trait that encapulates those bounds?</p>



<a name="225061878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061878">(Feb 03 2021 at 18:47)</a>:</h4>
<p>Well, my point was more that I'm unsure if the end result will have bounds or not. If we use generic integers it likely will not (or will have very different bounds)</p>



<a name="225061986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225061986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225061986">(Feb 03 2021 at 18:47)</a>:</h4>
<p>But part of the problem is a lot of the remaining math (like trig) require masks to implement</p>



<a name="225062159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062159">(Feb 03 2021 at 18:48)</a>:</h4>
<p>Right, we'll have a lot of the API blocked by the mask feature gate.</p>



<a name="225062175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062175">(Feb 03 2021 at 18:48)</a>:</h4>
<p>if we turn out to not need bounds we can just impl the encapulating trait for all sizes, which would avoid needing anyone to mention it anymore, but they can if they like</p>



<a name="225062294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062294">(Feb 03 2021 at 18:49)</a>:</h4>
<p>So the problem is that with const_evaluatable_checked a lot of the implementation details leak, so it's not even clear what that trait would look like</p>



<a name="225062611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062611">(Feb 03 2021 at 18:51)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">EncapsulatedBounds</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">LEN</span>: <span class="kt">usize</span><span class="o">&gt;</span>: <span class="nc">MustBeTrue</span><span class="o">&lt;</span><span class="p">{</span><span class="n">LEN</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">42</span><span class="p">}</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="225062687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062687">(Feb 03 2021 at 18:51)</a>:</h4>
<p>like C++'s enable_if</p>



<a name="225062695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062695">(Feb 03 2021 at 18:51)</a>:</h4>
<p>I wish the bound was that simple</p>



<a name="225062748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062748">(Feb 03 2021 at 18:52)</a>:</h4>
<p>The problem isn't limiting to a size unfortunately</p>



<a name="225062807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062807">(Feb 03 2021 at 18:52)</a>:</h4>
<p>It's ensuring that a particular implementation detail const fn doesn't panic</p>



<a name="225062836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062836">(Feb 03 2021 at 18:52)</a>:</h4>
<p>the expression can be replaced, the key part is the bound is part of the super-traits so is implicitly added</p>



<a name="225062935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225062935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225062935">(Feb 03 2021 at 18:53)</a>:</h4>
<p>Yeah, you may be able to do it with a supertrait.</p>



<a name="225064480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225064480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225064480">(Feb 03 2021 at 19:03)</a>:</h4>
<p>also <span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> you may have said it before but I do appreciate you taking the time to lay it all out again like that, because I think a lot of what we were missing was precisely that kind of synthesis. It's a lot easier to see the obstacles here, now that you've listed them off.</p>



<a name="225079742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225079742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225079742">(Feb 03 2021 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> here's the bound requirement for making bitmasks: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=9308b5824f77cca83b4736a65cee698c">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=9308b5824f77cca83b4736a65cee698c</a>.  I really can't come up with a way of hiding it behind a trait</p>



<a name="225085467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225085467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225085467">(Feb 03 2021 at 21:31)</a>:</h4>
<p>would this work:<br>
<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=f2817276e475392d89dfa8a4723c9327">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=f2817276e475392d89dfa8a4723c9327</a></p>



<a name="225086463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225086463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225086463">(Feb 03 2021 at 21:38)</a>:</h4>
<p>Unfortunately that doesn't really hide the bound in any way: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=09f21b104e7f96da31a0b3c28bd03830">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=09f21b104e7f96da31a0b3c28bd03830</a></p>



<a name="225087174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225087174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225087174">(Feb 03 2021 at 21:43)</a>:</h4>
<p>It seems like we should focus on trying to make it easy to use things in accord with the bound rather than trying to obscure the bound?</p>



<a name="225087268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225087268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225087268">(Feb 03 2021 at 21:44)</a>:</h4>
<p>Well, one issue with the bound is that it crashes rustdoc :)</p>



<a name="225087348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225087348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225087348">(Feb 03 2021 at 21:44)</a>:</h4>
<p>But I think that's the point, there isn't really any way to make it easier.  There is no way to modify how the bound is exposed afaik</p>



<a name="225087930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225087930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225087930">(Feb 03 2021 at 21:49)</a>:</h4>
<p>well you mentioned using a const fn bound and oof ow.</p>



<a name="225090508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225090508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225090508">(Feb 03 2021 at 22:09)</a>:</h4>
<p>Ok, <span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> you inspired me and I got it working with <em>no</em> bounds (!)</p>



<a name="225090522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225090522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225090522">(Feb 03 2021 at 22:09)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2ab588032db773ce90e9d2e40ae64703">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2ab588032db773ce90e9d2e40ae64703</a></p>



<a name="225090991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225090991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225090991">(Feb 03 2021 at 22:13)</a>:</h4>
<p>Unfortunately this doesn't work:</p>
<div class="codehilite"><pre><span></span><code>pub struct Mask16&lt;const LANES: usize&gt;(SimdU8&lt;{ MaskHelper::&lt;LANES&gt;::BITMASK_BYTES }&gt;)
where
    MaskHelper&lt;LANES&gt;: Sized;
</code></pre></div>



<a name="225091027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091027">(Feb 03 2021 at 22:14)</a>:</h4>
<p>wait what</p>



<a name="225091113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091113">(Feb 03 2021 at 22:14)</a>:</h4>
<p>I think I just punted the entire problem by not trying to hide the width of the bitmask</p>



<a name="225091133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091133">(Feb 03 2021 at 22:14)</a>:</h4>
<p>And instead providing a helper that tells you how wide it is</p>



<a name="225091135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091135">(Feb 03 2021 at 22:14)</a>:</h4>
<p>oh.</p>



<a name="225091270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091270">(Feb 03 2021 at 22:16)</a>:</h4>
<p>we <em>could</em> make a type like <code>struct Mask16&lt;const LANES: usize, const BYTES: usize&gt;(...)</code> if we really wanted</p>



<a name="225091287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091287">(Feb 03 2021 at 22:16)</a>:</h4>
<p>and then I think maybe it would work?</p>



<a name="225091408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091408">(Feb 03 2021 at 22:17)</a>:</h4>
<p>deranged question: is there a reason to have the "full mask" not be a SimdU{8,16, 32...}?</p>



<a name="225091877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091877">(Feb 03 2021 at 22:19)</a>:</h4>
<p>no that would be fine, but obviously the number of bytes changes</p>



<a name="225091950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091950">(Feb 03 2021 at 22:20)</a>:</h4>
<p>oh wait I misread</p>



<a name="225091971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091971">(Feb 03 2021 at 22:20)</a>:</h4>
<p>well in LLVM they're interpreted as signed, you can always transmute them</p>



<a name="225091997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225091997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225091997">(Feb 03 2021 at 22:20)</a>:</h4>
<p>the reason is that packing and unpacking the masks is sign extension and truncation</p>



<a name="225092236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225092236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225092236">(Feb 03 2021 at 22:22)</a>:</h4>
<p>okay so is this disgusting? you could define masks as</p>



<a name="225092403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225092403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225092403">(Feb 03 2021 at 22:24)</a>:</h4>
<div class="codehilite"><pre><span></span><code>pub struct Mask&lt;const LANE_WIDTH: usize, const BYTES: usize&gt; {
    mask: SimdU8&lt;BYTES&gt;,
    _: [(); LANE_WIDTH],
}
</code></pre></div>



<a name="225092449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225092449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225092449">(Feb 03 2021 at 22:24)</a>:</h4>
<p>you could get weird pathological cases like bizarre lane widths, or lane widths larger than the number of bytes in the mask</p>



<a name="225092904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225092904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225092904">(Feb 03 2021 at 22:28)</a>:</h4>
<p>but you could implement a trait over scalars that tells you the lane width (which on SimpleV etc would always be 1)</p>



<a name="225093025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225093025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225093025">(Feb 03 2021 at 22:29)</a>:</h4>
<p>treating the (sigh) bitfields?? really??? as I{whatever} would not be the end of the world, even if it's against Rust idiom.</p>



<a name="225093179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225093179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225093179">(Feb 03 2021 at 22:30)</a>:</h4>
<p>I suppose you could instead of specifying LANE_WIDTH, just specify LANES</p>



<a name="225093186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225093186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225093186">(Feb 03 2021 at 22:30)</a>:</h4>
<p>it's the same idea</p>



<a name="225093199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225093199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225093199">(Feb 03 2021 at 22:31)</a>:</h4>
<p>but yeah, it's bit-field-ish</p>



<a name="225102287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102287">(Feb 04 2021 at 00:09)</a>:</h4>
<p>So... A really dumb suggestion, maybe, but solves nearly all of our issues</p>



<a name="225102326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102326">(Feb 04 2021 at 00:09)</a>:</h4>
<p>What if we just extremely over-pad packed masks and use [u8; LANES]</p>



<a name="225102425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102425">(Feb 04 2021 at 00:10)</a>:</h4>
<p>sure why not.</p>



<a name="225102474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102474">(Feb 04 2021 at 00:11)</a>:</h4>
<p>And maybe push for generic integers in the meantime?</p>



<a name="225102495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102495">(Feb 04 2021 at 00:11)</a>:</h4>
<p>Yeah.</p>



<a name="225102668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102668">(Feb 04 2021 at 00:13)</a>:</h4>
<p>alternatively, cap vectors at 128 lanes?</p>



<a name="225102717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102717">(Feb 04 2021 at 00:14)</a>:</h4>
<p>and just use u128 always?</p>



<a name="225102742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102742">(Feb 04 2021 at 00:14)</a>:</h4>
<p>that's still quite a few lanes</p>



<a name="225102761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102761">(Feb 04 2021 at 00:14)</a>:</h4>
<p>or even just cap at 64 lanes, since many architectures seem to use that as the mask size typically</p>



<a name="225102800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102800">(Feb 04 2021 at 00:15)</a>:</h4>
<p>Yeah AVX512 pretty explicitly uses that.</p>



<a name="225102815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102815">(Feb 04 2021 at 00:15)</a>:</h4>
<p>AVX-512 is actually only 16 bits</p>



<a name="225102817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102817">(Feb 04 2021 at 00:15)</a>:</h4>
<p>oh?</p>



<a name="225102820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102820">(Feb 04 2021 at 00:15)</a>:</h4>
<p>AVX-512BW is 64</p>



<a name="225102826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102826">(Feb 04 2021 at 00:15)</a>:</h4>
<p>...I think it might've been the</p>



<a name="225102830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102830">(Feb 04 2021 at 00:15)</a>:</h4>
<p>...yeah that.</p>



<a name="225102985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225102985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225102985">(Feb 04 2021 at 00:17)</a>:</h4>
<p>So, in keeping with the spirit of poasting about how we should keep in mind what limitations are coming from where,<br>
I think u64 as our current bitmask type sounds good.<br>
But we should probably chase down all the actual different constraints we are encountering, what instructions use what.</p>



<a name="225103099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225103099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225103099">(Feb 04 2021 at 00:18)</a>:</h4>
<p>I suppose if we make a <code>Mask</code> trait we could just implement it over all integers? Not that I really wanted to use a trait here... but it would work</p>



<a name="225103177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225103177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225103177">(Feb 04 2021 at 00:19)</a>:</h4>
<p>I just don't want to end up in the situation where in the future we want to expand the size of the bitmask, and we break a bunch of existing code by making it really slow</p>



<a name="225121466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121466">(Feb 04 2021 at 05:42)</a>:</h4>
<p>So, limiting to 64 lanes actually worked really well.  Just like arrays pre 1.47, it will be annoying to write traits over masks, but I don't think we need that to start.</p>



<a name="225121469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121469">(Feb 04 2021 at 05:42)</a>:</h4>
<p>PR is up :)</p>



<a name="225121482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121482">(Feb 04 2021 at 05:42)</a>:</h4>
<p>Nice!</p>



<a name="225121573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121573">(Feb 04 2021 at 05:45)</a>:</h4>
<p>So one thing I didn't really account for is that limiting masks to 64 will probably end up limiting checked arithmetic ops to 64 as well</p>



<a name="225121585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121585">(Feb 04 2021 at 05:45)</a>:</h4>
<p>alternatively, we will need to rely on autovectorization for those</p>



<a name="225121631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121631">(Feb 04 2021 at 05:46)</a>:</h4>
<p>(or some other hack)</p>



<a name="225121654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121654">(Feb 04 2021 at 05:47)</a>:</h4>
<p>I think we will see at least one wholesale revision of the API for masks, so at this point I am unafraid to make any decision whatsoever so that we can get it in front of other people and make it a somewhat bigger discussion. :^)</p>



<a name="225121658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225121658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225121658">(Feb 04 2021 at 05:47)</a>:</h4>
<p>see if anyone shakes out anything we're missing lol</p>



<a name="225191403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225191403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225191403">(Feb 04 2021 at 17:14)</a>:</h4>
<p>...also an LLVM person just decided to start talking to me spontaneously so I guess I'm going to ask him about i1.</p>



<a name="225193222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225193222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225193222">(Feb 04 2021 at 17:28)</a>:</h4>
<p>"ooh, that's a rough corner case." haha we're doomed.</p>



<a name="225193449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225193449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225193449">(Feb 04 2021 at 17:30)</a>:</h4>
<p>Haha</p>



<a name="225193477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225193477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225193477">(Feb 04 2021 at 17:30)</a>:</h4>
<p>Oops.</p>



<a name="225193489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225193489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225193489">(Feb 04 2021 at 17:30)</a>:</h4>
<p>OK, but seriously, if you could ask, hypothetically, the LLVM developer group about i1xN, what would you ask?</p>



<a name="225193711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225193711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225193711">(Feb 04 2021 at 17:32)</a>:</h4>
<p>Are there any gotchas to bitcasting it to a larger width integer</p>



<a name="225193749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225193749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225193749">(Feb 04 2021 at 17:32)</a>:</h4>
<p>None stood out from reading the mailing lists</p>



<a name="225197405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225197405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225197405">(Feb 04 2021 at 17:59)</a>:</h4>
<p>Why are i1xN probl3matic? Are those like 1 bit booleans into a 32/64/128/256 bit lane?</p>



<a name="225197705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225197705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225197705">(Feb 04 2021 at 18:01)</a>:</h4>
<p>Really the only odd thing about them is their alignment.  They align to byte boundaries but only take up 1 bit and can be packed together into a single byte</p>



<a name="225197995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225197995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225197995">(Feb 04 2021 at 18:03)</a>:</h4>
<p>Oh , gotcha.</p>



<a name="225208876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225208876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225208876">(Feb 04 2021 at 19:22)</a>:</h4>
<p>OK, so, I think I should fully explain the whole "we're trying to square the circle re: bitmasks and fullmasks" bit, and then say we're looking primarily at using i1 for that with sign extensions/bitcasting where necessary?</p>



<a name="225212307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%20%28take%203%3F%204%3F%29/near/225212307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.20(take.203.3F.204.3F).html#225212307">(Feb 04 2021 at 19:47)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I can review your PR once we have a test for mask ops (does not have to be comprehensive or cover every length, etc., just "please demo the API").</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>